package core;

import org.apache.commons.lang3.BooleanUtils;

import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.ext.handler.ContextPathHandler;
import com.jfinal.plugin.ehcache.EhCachePlugin;

import kit.token.TokenConfiguration;
import web.controller.JwtController;

public class CoreConfig extends JFinalConfig {
	@Override
	public void configConstant(Constants me) {
		loadPropertyFile("db.properties");
		me.setDevMode(BooleanUtils.toBoolean(getProperty("DEV_MODE")));
		me.setBaseViewPath("/WEB-INF/templates");// 页面模板根路径
		me.setError404View("/404.html");
		me.setError500View("/500.html");
	}

	@Override
	public void configRoute(Routes me) {
		me.add("/jwt", JwtController.class);

	}
	@Override
	public void configPlugin(Plugins me) {
		me.add(new EhCachePlugin());
	}

	@Override
	public void configInterceptor(Interceptors me) {
	}

	@Override
	public void configHandler(Handlers me) {
		ContextPathHandler path = new ContextPathHandler("ctx");
		me.add(path);
	}

	@Override
	public void afterJFinalStart() {
		TokenConfiguration.init();
	}

	@Override
	public void beforeJFinalStop() {
	}
}